package com.example.interpreter2;

import java.util.ArrayList;

public class ExpressionNode implements Node {

    private ArrayList<Node> nodes = new ArrayList<>();

    @Override
    public void interpret(Context context) {
        while (true) {
            if (null == context.getCurrentToken()) {
                break;
            }
            if (context.getCurrentToken().equals("END")) {
                context.skipToken("END");
                break;
            }
            Node node = new CommandNode();
            node.interpret(context);
            nodes.add(node);
        }
    }

    @Override
    public void execute() {
        for (Node node : nodes) {
            node.execute();
        }
    }

}
